<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box{
            width: 500px;
            height: 100px;
            border: 2px solid rosybrown;
        }
    </style>
</head>
<body>
    <input type="text" id="text1">&nbsp;
    <button id="a1">复制</button>
    <button id="a2">清除</button>
    <div id="box">    
    </div>
<script>
    var div =document.querySelector('box')
    var text1 =document.querySelector('#text1')
    var a1=document.querySelector('#a1')
    var h2=document.createElement('h2')
    a1.onclick=() =>{
        var a=text1.value
        var newh2=document.createElement('h2')
        var txt=document.createTextNode(a)
        newh2.appendChild(txt)
        
        box.appendChild(newh2)
        text1.value='';
                
        
    }
    var a2 =document.querySelector('#a2')
    a2.onclick=() =>{
        var droph2=document.getElementById('')
        var h21=document
        div.removeChild(droph2)
        console.log(droph2);
    }    
  
  
    
  
</script>
</body>
</html>